package com.app.samba.thread;

import com.app.samba.DebugLog;
import com.app.samba.bean.LocalMediaBean;
import com.app.samba.util.SambaUtil;

import java.util.List;

import jcifs.smb.NtlmPasswordAuthentication;

import static com.app.samba.DebugLog.SAMBA_DOWN_UP;

/**
 * Created Date 2019/7/1
 *
 * @author liangkun
 * description：
 */
public class DownRunnable implements Runnable {
    String host = "192.168.31.76"; //samba--ip 本地电脑的
    String uploadPath = "/图片电影音乐素材/upload/"; //上传samba服务器的文件夹
    private int threadNum;
//    private List<LocalMediaBean> mediaBeans;
    private String path;

    public DownRunnable(String path, int threadNum) {
        this.threadNum = threadNum;
        this.path = path;
    }


    @Override
    public void run() {
        String remoutUrl = "smb://" + host + uploadPath;
        uploadRequest(remoutUrl, path);


    }

    /**
     * 下载文件
     *
     * @param remoutUrl samba URL
     * @param path      上传文件的路径资源
     */
    private void uploadRequest(String remoutUrl, String path) {
        DebugLog.d(SAMBA_DOWN_UP + "进入 downLoadRequest() ...." + " remoteUrl " + remoutUrl + " path " + path);
        String username = "administrator";
        String password = "065021";
        NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication(host, username, password);
        try {
            SambaUtil.uploadFileToSamba(remoutUrl, auth, path);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

